#pragma once

#include "clkFsmCartridge.h"

enum FSM_CODE
{
	SYS_SUCCESS,
	SYS_CART_EMPTY,
};

class clkFsmSystem
{
public:
	//attributes
	bool m_powered;
	bool m_next;
	bool m_prev;
	bool m_change;
	clkFsmData* m_data;

	int m_powerOffId;
	clkFsmCartridge* m_current;
	vector<clkFsmCartridge*> m_fsmList;

	//ctor
	clkFsmSystem()
		: m_powered(false),
		m_next(false),
		m_prev(false),
		m_powerOffId(-1),
		m_current(0),
		m_data(0){}

	//cartidge looper
	virtual void init();
	virtual void reset();
	virtual void shut();
	virtual void update();
	
	//system commands
	int powerOnSystem();
	int powerOffSystem();
	int checkCartridge();
	int swapCartridge();

	void nextCartridge();
	void prevCartridge();
	void systemData(clkFsmData* a_data);
	void queueCartridge(clkFsmCartridge* a_cartridge,
		int a_selfId, int a_swapId = -1, bool a_renew = true);
	void powerOffId(int a_id){m_powerOffId = a_id;}
	
	bool stateCompleted(){return m_current->m_completed;}
	bool isPowered(){return m_powered;}
	bool inNextTransition(){return m_next;}
	bool inPrevTransition(){return m_prev;}
};